home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 May / macformat-024.iso / Shareware City / Developers / TurboTCP 2.1 / TCL helper classes / CTCPSessionDoc.cp < prev    next >
Encoding:
Text File  |  1995-01-06  |  1.3 KB  |  60 lines  |  [TEXT/MMCC]

  1. //
  2. // CTCPSessionDoc.cp
  3. //
  4. //    TurboTCP library
  5. //    TCP session document
  6. //    TCL-specific class
  7. //
  8. //    Copyright © 1993-95, FrostByte Design / Eric Scouten
  9. //
  10.  
  11. #include "CTCPSessionDoc.h"
  12.  
  13. #if !TurboTCP_TCL
  14.     #error: This file should be used with TCL projects only!
  15. #endif
  16.  
  17.  
  18. // -- closing windows & sessions --
  19.  
  20. //***********************************************************
  21.  
  22. Boolean CTCPSessionDoc::Close
  23.     (Boolean quitting)                // true if the application is quitting
  24.  
  25.     // Respond to user close. Ensure that the TCP stream is gracefully closed. (This method is
  26.     // also called if the remote host closes the session or the session is terminated.)
  27.     
  28.     // Returns false if close/quit aborted by user.
  29.  
  30. {
  31.     closeAndQuit = quitting;                        // do we really want to close?
  32.     if (!ConfirmClose(quitting))
  33.         return false;
  34.  
  35.     if (itsFile)                                // close file first
  36.         itsFile->Close();
  37.  
  38.     if (!LocalClose(quitting))                        // now close stream
  39.         return false;
  40.  
  41.     return CDirector::Close(quitting);
  42.  
  43. }
  44.  
  45.  
  46. //***********************************************************
  47.  
  48. void CTCPSessionDoc::RemoteClose()
  49.  
  50.     // Respond to notification that the remote host cancelled the session (either by normal
  51.     // close or terminate).
  52.  
  53. {
  54.     Boolean sessionWasEstablished = SessionEstablished();
  55.  
  56.     CTCPEndpoint::RemoteClose();
  57.     if ((goAwayOnClose) && (!sessionWasEstablished))
  58.         Close(false);
  59. }
  60.